home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / JPEG Convert 1.0 Source / JPEG Convert.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-05  |  7.3 KB  |  248 lines  |  [TEXT/KAHL]

  1. /*
  2.  * JPEG Convert.h
  3.  *
  4.  * Copyright (C) 1992, James H. Brunner.
  5.  *
  6.  * This file is part of the "JPEG Convert" program.  The JPEG Convert program signature ('Ijgp')
  7.  * and unique file types ('TARG', 'RLE ', 'PPM ') are registered with Apple by the author.
  8.  *
  9.  * The JPEG Convert program is an image format conversion program that utilizes the software of
  10.  * the Independent JPEG Group.  The JPEG Convert program is essentially a Macintosh user interface
  11.  * around the Independent JPEG Group's code.  The author of JPEG Convert maintains a copyright to
  12.  * the interface software only.  For conditions of distribution and use of the Independent JPEG
  13.  * Group's software, refer to the README file contained in the Independent JPEG Group's distribution
  14.  * package.
  15.  *
  16.  * (Further use of the word 'software' refers only to the source files for implementing this user
  17.  *  interface, including the resource file which does not include this comment. It does NOT refer
  18.  *  to the Independent JPEG Group's code.)
  19.  *
  20.  * The conditions for distribution of this software are as follows:
  21.  *        This software may be freely distributed provided that it is not distributed for profit; a
  22.  *        nominal copying fee may be charged.
  23.  *
  24.  *        Any distribution of this software must contain all original copyright notices.
  25.  *
  26.  * The conditions for use of this software IN FULL are as follows:
  27.  *        This software may be used in full by any person or business provided that the person or
  28.  *        business is not seeking profits directly from the use of this software.
  29.  *
  30.  * The conditions for use of this software IN PART are as follows:
  31.  *        Any person or business may copy and utilize portions of this software in other products
  32.  *        provided that a note that "portions of the software are copyright by James H. Brunner"
  33.  *        is included in the software AND the resultant software is not intended to be distributed
  34.  *        for profit.
  35.  *
  36.  *        If SOURCE for projects containing portions of this code is not to be made available
  37.  *        with the resultant programs, an additional note that "portions of the software are 
  38.  *        copyright James H. Brunner" must be included in some visable user documentation.
  39.  *
  40.  * Bottom line:  I give it away free; I don't want you selling it.  You can use the source if
  41.  * you wish, but don't sell it.  If you use my work, give me credit for it.
  42.  */
  43.  
  44. /*
  45.  * JPEG Convert.h
  46.  *
  47.  * This header file contains common information between the other source files that implement the
  48.  * interface.  I did not use "MacHeaders" because, since I'm distributing this as source, I don't
  49.  * know what other folks have done to their MacHeader file.
  50.  */
  51.  
  52. /* MAC INCLUDES */
  53. #include <Dialogs.h>
  54. #include <Think.h>
  55. #include <ToolUtils.h>
  56. #include <AppleEvents.h>
  57. #include <Types.h>
  58. #include <StandardFile.h>
  59. #include <Pascal.h>
  60. #include <Errors.h>
  61. #include <Resources.h>
  62.  
  63. /* INDEPENDENT JPEG GROUP INCLUDES */
  64. #include "jinclude.h"
  65.  
  66. /* This is the application signature that is registered with Apple Computer */
  67. #define appSignature    'Ijgp'
  68.  
  69. /* MISC DEFINES */
  70. #define MAXINT    32767
  71.  
  72. /* DEFINES FOR DIALOG ITEMS IN THE CJPEG AND DJPEG DIALOGS */
  73. #define J_OK        1
  74. #define J_OK_ALL    2
  75. #define J_CAN        3
  76. #define J_SETFILE    4
  77. #define J_INFILE    5
  78. #define J_OUTFILE    6
  79. #define CJ_QUALITY    7
  80. #define CJ_OPT        8
  81. #define    CJ_GRAY        9
  82. #define CJ_TARGA    10
  83. #define CJ_NONINTER    11
  84. #define CJ_ARITH    12
  85. #define CJ_DEBUG    13
  86. #define CJ_OKBORDER    19
  87. #define DJ_GIF        7
  88. #define DJ_PPM        8
  89. #define DJ_RLE        9
  90. #define DJ_TARGA    10
  91. #define DJ_QUANTIZE    11
  92. #define DJ_Q_COLORS    12
  93. #define DJ_Q_NODITHER    13
  94. #define DJ_Q_1PASS    14
  95. #define DJ_GRAY        15
  96. #define DJ_SMOOTH    16
  97. #define DJ_DEBUG    17
  98. #define DJ_OKBORDER    24
  99. #define DJ_DIMCOLORS    25
  100.  
  101. /* DEFINE DIFFERENT OUTPUT FILE FORMATS */
  102. typedef enum {
  103.     FMT_GIF=DJ_GIF,    /* GIF format */
  104.     FMT_PPM,        /* PPM/PGM (PBMPLUS formats) */
  105.     FMT_RLE,        /* RLE format */
  106.     FMT_TARGA,        /* Targa format */
  107.     FMT_JPEG
  108. } ImageFormat;
  109.  
  110. #ifndef DEFAULT_FMT        /* so can override from prefix in project */
  111. #define DEFAULT_FMT    FMT_GIF
  112. #endif
  113.  
  114.  
  115. /* DATA GATHERED FROM THE DJPEG DIALOG */
  116. typedef struct    {
  117.                     Boolean            smoothing;
  118.                     Boolean            grayscale;
  119.                     Boolean            quantize;
  120.                     short            colors;
  121.                     Boolean            onepass;
  122.                     Boolean            nodither;
  123.                     short            debug;
  124.                     FSSpec            outfile;
  125.                     Boolean            replace_ok;
  126.                     ImageFormat        format;
  127.                 } djpeg_dlog_data;
  128.  
  129.  
  130. /* DATA GATHERED FROM THE CJPEG DIALOG */
  131. typedef struct    {
  132.                     short        quality;
  133.                     Boolean        grayscale;
  134.                     Boolean        targa;
  135.                     Boolean        optimize;
  136.                     Boolean        arithmetic;
  137.                     Boolean        nointerleave;
  138.                     FSSpec        outfile;
  139.                     Boolean        replace_ok;
  140.                     short        debug;
  141.                 } cjpeg_dlog_data;
  142.                         
  143. /* PREFERENCES DATA */
  144. #define PREF_VERSION    1
  145. typedef struct    {
  146.                     short        pref_version;
  147.                     Point        progressLoc;
  148.                     OSType        jpeg_type;
  149.                     OSType        jpeg_creator;
  150.                     OSType        gif_type;
  151.                     OSType        gif_creator;
  152.                     OSType        ppm_type;
  153.                     OSType        ppm_creator;
  154.                     OSType        targa_type;
  155.                     OSType        targa_creator;
  156.                     OSType        rle_type;
  157.                     OSType        rle_creator;
  158.                     Boolean        overwrite;
  159.                     Boolean        show_all;
  160.                 } prefs_data, **PrefHandle;
  161.  
  162.  
  163. /* PROTOTYPES OF ROUTINES */
  164.  
  165. GLOBAL void
  166. Error (OSErr eCode, unsigned char *p1, unsigned char *p2);
  167.  
  168. GLOBAL short
  169. display_djpeg_dialog (FSSpec infile, djpeg_dlog_data *dlog_info);
  170.  
  171. GLOBAL short
  172. display_cjpeg_dialog (FSSpec infile, cjpeg_dlog_data *dlog_info);
  173.  
  174. GLOBAL void
  175. display_prefs_dialog (void);
  176.  
  177. GLOBAL void
  178. fix_name (Str255 outname, Str255 inname, int format);
  179.  
  180. GLOBAL OSErr
  181. FSSpecToName (FSSpec spec, Str255 fullname);
  182.  
  183. GLOBAL void
  184. CenterDialog (short id, Point *corner);
  185.  
  186. GLOBAL void
  187. PutFile (ConstStr255Param prompt, ConstStr255Param defaultName, StandardFileReply *reply);
  188.  
  189. GLOBAL pascal void
  190. NOPRoutine (WindowPtr dwind, short dinum);
  191.  
  192. GLOBAL pascal void
  193. BorderDefault (WindowPtr dwind, short dinum);
  194.  
  195. GLOBAL Boolean
  196. ReturnEnterEscape (DialogPtr d, EventRecord *theEvent, short *item);
  197.  
  198. GLOBAL void
  199. read_preference_file (void);
  200.  
  201. GLOBAL Handle
  202. ditemh (DialogPtr theDialog, short item);
  203. #define CITEMH(d, i)    (ControlHandle)ditemh(d, i)
  204.  
  205. GLOBAL void
  206. DoAboutBox (void);
  207.  
  208. GLOBAL OSErr
  209. xFSMakeFSSpec (short vRefNum, long dirID, ConstStr255Param fileName, FSSpecPtr spec);
  210.  
  211. GLOBAL OSErr
  212. xFSpCreateResFile (const FSSpec    *spec, OSType creator, OSType fileType, ScriptCode scriptTag);
  213.  
  214. GLOBAL short
  215. xFSpOpenResFile (const FSSpec *spec, SignedByte permission);
  216.  
  217. pascal OSErr
  218. SetDialogDefaultItem (DialogPtr theDialog, short newItem)     = {0x303C, 0x0304, 0xAA68};
  219.  
  220. pascal OSErr
  221. SetDialogCancelItem (DialogPtr theDialog, short newItem)     = {0x303C, 0x0305, 0xAA68};
  222.  
  223. pascal OSErr
  224. GetStdFilterProc (ModalFilterProcPtr *theProc)                 = {0x303C, 0x0203, 0xAA68};
  225.  
  226. pascal OSErr
  227. SetDialogTracksCursor (DialogPtr theDialog, Boolean tracks)    = {0x303C, 0x0306, 0xAA68};
  228.  
  229.  
  230. /* Stuff for Pascal type strings ... */
  231.  
  232. #define CSTR            char *
  233. #define    PSTR            unsigned char *
  234.  
  235. /* concatonate 2 Pascal strings:  a = CONCAT(b, c).  Assumes Str255.  Truncates if necessary. */
  236. #define CONCAT(a, b, c)    do {    int    cchars;                                                        \
  237.                                 cchars = ((int)b[0] + (int)c[0]  > 255 ? 255 - b[0] : c[0]);    \
  238.                                 if (&a[0] == &b[0]) {                                            \
  239.                                     BlockMove(&c[1], &a[a[0]+1], cchars);                        \
  240.                                     a[0] += cchars;                                                \
  241.                                 } else {                                                        \
  242.                                     BlockMove(&c[1], &a[1 + b[0]], cchars);                        \
  243.                                     BlockMove(&b[1], &a[1], b[0]);                                \
  244.                                     a[0] = b[0] + cchars;                                        \
  245.                                 }                                                                \
  246.                             } while (0)
  247. #define COPY(target, source)    BlockMove(source, target, *source+1);                            
  248.